package com.yingxin.yx.framework.commons.enums;

import java.util.ArrayList;
import java.util.List;

@SuppressWarnings("all")
public enum ContractType {
    // rezha suanxi zhaying duxin caitu
    // hot pickling cold galvanized color
    RZ_CGHT("RZ_CGHT", "热轧采购合同", MaterialType.RZ, ContractCategory.CGHT),
    SX_CGHT("SX_CGHT", "酸洗采购合同", MaterialType.SX, ContractCategory.CGHT),
    ZY_CGHT("ZY_CGHT", "轧硬采购合同", MaterialType.ZY, ContractCategory.CGHT),
    DX_CGHT("DX_CGHT", "镀锌采购合同", MaterialType.DX, ContractCategory.CGHT),
    DX_AR_CGHT("DX_AR_CGHT", "镀锌(安融)采购合同", MaterialType.DX, ContractCategory.CGHT ),
    CT_CGHT("CT_CGHT", "彩涂采购合同", MaterialType.CT, ContractCategory.CGHT),

    XD_CGHT("XD_CGHT", "锌锭采购合同", MaterialType.XD, ContractCategory.CGHT),
    XLTZD_CGHT("XLTZD_CGHT", "锌铝调整锭采购合同", MaterialType.XLTZD, ContractCategory.CGHT),
    XTTZD_CGHT("XTTZD_CGHT", "锌锑调整锭采购合同", MaterialType.XTTZD, ContractCategory.CGHT),


    RZ_SX_DGHT("RZ_SX_DGHT", "热轧代工酸洗合同", MaterialType.RZ, ContractCategory.DGHT),
    RZ_ZY_DGHT("RZ_ZY_DGHT", "热轧代工轧硬合同", MaterialType.RZ, ContractCategory.DGHT),
    SX_ZY_DGHT("SX_ZY_DGHT", "酸洗代工轧硬合同", MaterialType.SX, ContractCategory.DGHT),
    ZY_DX_DGHT("ZY_DX_DGHT", "轧硬代工镀锌合同", MaterialType.ZY, ContractCategory.DGHT),
    ZY_CT_DGHT("ZY_CT_DGHT", "轧硬代工彩涂合同", MaterialType.ZY, ContractCategory.DGHT),
    DX_CT_DGHT("DX_CT_DGHT", "镀锌代工彩涂合同", MaterialType.DX, ContractCategory.DGHT),


    SX_SJ_XSHT("SX_SJ_XSHT", "酸洗锁价合同", MaterialType.SX, ContractCategory.XSHT),
    ZY_SJ_XSHT("ZY_SJ_XSHT", "轧硬锁价合同", MaterialType.ZY, ContractCategory.XSHT),
    ZY_YJ_XSHT("ZY_YJ_XSHT", "轧硬月结合同", MaterialType.ZY, ContractCategory.XSHT),
    ZY_FL_XSHT("ZY_FL_XSHT", "轧硬废料合同", MaterialType.ZY, ContractCategory.XSHT),
    DX_SJ_XSHT("DX_SJ_XSHT", "镀锌锁价合同", MaterialType.DX, ContractCategory.XSHT),
    DX_XS_XSHT("DX_XS_XSHT", "镀锌销售合同", MaterialType.DX, ContractCategory.XSHT),
    DX_YJ_XSHT("DX_YJ_XSHT", "镀锌月结合同", MaterialType.DX, ContractCategory.XSHT),
    DX_FL_XSHT("DX_FL_XSHT", "镀锌废料合同", MaterialType.DX, ContractCategory.XSHT),
    DX_AR_XSHT("DX_AR_XSHT", "镀锌安融合同", MaterialType.DX, ContractCategory.XSHT),
    CT_SJ_XSHT("CT_SJ_XSHT", "彩涂锁价合同", MaterialType.CT, ContractCategory.XSHT),


    QTHT("QTHT", "其他合同", null, ContractCategory.QTHT);


    private String type;

    private String typeName;

    private MaterialType materialType;

    private ContractCategory category;

    ContractType(String type, String typeName, MaterialType materialType, ContractCategory category) {
        this.type = type;
        this.typeName = typeName;
        this.materialType = materialType;
        this.category = category;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getTypeName() {
        return typeName;
    }

    public void setTypeName(String typeName) {
        this.typeName = typeName;
    }

    public MaterialType getMaterialType() {
        return materialType;
    }

    public void setMaterialType(MaterialType materialType) {
        this.materialType = materialType;
    }

    public ContractCategory getCategory() {
        return category;
    }

    public void setCategory(ContractCategory category) {
        this.category = category;
    }


    public static ContractType getEnum(String type) {
        for (ContractType ct : ContractType.values()) {
            if (ct.getType().equals(type)) {
                return ct;
            }
        }
        return null;
    }

    public static ContractType getEnum(String type, ContractCategory category) {
        for (ContractType ct : ContractType.values()) {
            if (category != null) {
                if (!ct.getCategory().equals(category)) {
                    continue;
                }
            }
            if (ct.getType().equals(type)) {
                return ct;
            }
        }
        return null;
    }

    public static List<ContractType> listEnumByCategory(ContractCategory category) {
        List<ContractType> list = new ArrayList<>();
        for (ContractType ct : ContractType.values()) {
            if (ct.getCategory().equals(category)) {
                list.add(ct);
            }
        }
        return list;
    }


    public static List<ContractType> listEnumByMaterialType(MaterialType materialType) {
        List<ContractType> list = new ArrayList<>();
        for (ContractType ct : ContractType.values()) {
            if (ct.getCategory().equals(ContractCategory.CGHT)
                    || ct.getCategory().equals(ContractCategory.DGHT)) {
                if (ct.getMaterialType().equals(materialType)) {
                    list.add(ct);
                }
            }
        }
        return list;
    }

}
